function [accuracy, ylabel]=call_CCCE(piSet, SSet, true_label, alpha, lambda, numiter)

format long;

ncl=size(piSet,2); % number of classes
N=size(piSet,1); % number of data points
%declaring constants
errctrlr=0.000000001; % to avoid log(zero)
MAXCOUNT=numiter;

%lagrangian multipliers for maintaining consistency between right and left copies
lambdal=lambda*ones(N,1);
lambdar=lambdal;

%uniform class assignment for unlabeled points
ind=find(diag(piSet*piSet')==0);
if(isempty(ind)==0)
 piSet(ind,:)=1/ncl;
end
piSet=piSet+errctrlr;
piSet=piSet./repmat(sum(piSet,2),1,ncl); 

%initialization of class assignment probability vector
yl=ones(N,ncl); %left copy
yl=yl./repmat(sum(yl,2),1,ncl); 
yr=yl; %right copy


objval=evaluate_obj(piSet, SSet, yl, yr, lambdal, lambdar, alpha);
iterativeobj(1)=objval;

for count=1:MAXCOUNT
 count;   
 for j=1:N
 
  %first step
  gammajr=alpha*sum(SSet(:,j));
  deltajr=SSet(:,j)/sum(SSet(:,j));
  term1=gammajr*deltajr'*yl;
  term2=lambdar(j)*yl(j,:);
  yr(j,:)=[piSet(j,:)+term1+term2]/(1+gammajr+lambdar(j));
  

  %objvalf=evaluate_obj(piSet, SSet, yl, yr, lambdal, lambdar, alpha);
  
  %second step
  i=j;
  gammail=alpha*sum(SSet(i,:));
  deltail=SSet(i,:)/sum(SSet(i,:));
  gradyr=1+log(yr+errctrlr);
  term3=gammail*(deltail*gradyr);
  term4=lambdal(j)*gradyr(j,:);
  temp=[term3+term4]/(gammail+lambdal(j));
  yl(i,:)=exp(temp-1);
  
  %objvals=evaluate_obj(piSet, SSet, yl, yr, lambdal, lambdar, alpha);
  
%   if(objvals>objvalf)
%       disp('error');  % error (very small in %) might occur due to 
%       % numerical precision problem and addition of errorcontroller..this might stay
%       % only for first few iterations and will eventually go away
%       objvalf;
%       objvals;
%   end
 end
 objval=evaluate_obj(piSet, SSet, yl, yr, lambdal, lambdar, alpha);
 iterativeobj(count+1)=objval;
end

yl=yl./repmat(sum(yl,2),1,ncl);
yr=yr./repmat(sum(yr,2),1,ncl);
y=[yl+yr]/2;
finalobjval=evaluate_obj(piSet, SSet, y, y, lambdal, lambdar, alpha);
[ymax ylabel]=max(y');
accuracy=100*length(find(ylabel'==true_label))/N;
xx=[1:count+1];
plot(xx,iterativeobj);
ylabel=ylabel';
% accuracy(count)
% max(accuracy)
%
end

